<template>
	<view class="container">
    <view v-if="loginByFacebook" class="list-cell b-b m-t" @click="navTo('../setting/profile/index')" hover-class="cell-hover" :hover-stay-time="50">
    	<text class="cell-tit">FaceBook</text>
      <text class="cell-tip">{{profileName}}</text>
    </view>
		<view class="list-cell b-b" :class="{'m-t': !loginByFacebook}" @click="navTo('../setting/profile/index')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">{{$t('setting.profile')}}</text>
			<image mode="aspectFit" style="width: 30upx; height: 30upx;" :src="staticUrl + 'fh2.png'">
		</view>
	   <!-- <view class="list-cell" @click="navTo('/pages/bdtel/bdtel')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">手機已繫結</text>
			<text class="cell-more yticon icon-you"></text>
		</view> -->
		
<!-- 		<view class="list-cell m-t">
			<text class="cell-tit">訊息推送</text>
			<switch checked color="#fa436a" @change="switchChange" />
		</view> -->
		<!-- <view class="list-cell m-t b-b" @click="navTo('清除快取')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">清除快取</text>
			<text class="cell-more yticon icon-you"></text>
		</view> -->
		<!-- <view class="list-cell b-b" @click="navTo('/pages/about/index')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">{{$t('about.title')}}</text>
			<image mode="aspectFit" style="width: 30upx; height: 30upx;" :src="staticUrl + 'fh2.png'">
		</view> -->
<!-- 		<view class="list-cell">
			<text class="cell-tit">聯絡我們</text>
			<text class="cell-tip">15885388639</text>
			<text class="cell-more yticon icon-you"></text>
		</view> -->
		<view class="list-cell log-out-btn" @click="toLogout">
			<text class="cell-tit">{{$t("login.logout")}}</text>
		</view>
	</view>
</template>

<script>
	import {  
	    mapMutations  
	} from 'vuex';
  import { isOnFacebookApp } from '@/utils/ua'
	export default {
		data() {
			return {
        staticUrl:this.$config.staticUrl,
        loginByFacebook: false,
        profileName: ''
			}
		},
		onLoad() {
		},
    computed: {
      isOnFacebook () {
        return isOnFacebookApp()
      },
    },
		methods:{
			...mapMutations(['logout']),
			navTo(url){
				uni.navigateTo({
					url:url
				})
			},
			//退出登入
			toLogout(){
        const that = this
				uni.showModal({
				    content: that.$t("login.logout.comfrim"),
				    success: (e)=>{
				    	if(e.confirm){
				    		uni.removeStorageSync('userinfo');
                
                const loginType = uni.getStorageSync('userLoginType')
                  
                if (loginType == 'facebook') {
                  try {
                    if (that.loginByFacebook) {
                      FB && FB.logout(function(response) {
                         // Person is now logged out
                      })
                    }
                  } catch {
                    
                  }
                }
                
                  
                if (loginType == 'google' && window.google) {
                  google.accounts.id.disableAutoSelect();
                }
                
                setTimeout(()=>{
                	// uni.navigateBack();
                  uni.reLaunch({
                    url: '/pages/client/index'
                  })
                }, 200)
				    	}
				    }
				});
			},
			//switch
			switchChange(e){
				let statusTip = e.detail.value ? '開啟': '關閉';
				this.$api.msg(`${statusTip}訊息推送`);
			},

		}
	}
</script>

<style lang='scss'>
	page{
		background: $page-color-base;
	}
	.list-cell{
		display:flex;
		align-items:baseline;
		padding: 20upx $page-row-spacing;
		line-height:60upx;
		position:relative;
		background: #fff;
		justify-content: center;
		&.log-out-btn{
			margin-top: 40upx;
			.cell-tit{
				color: $uni-color-primary;
				text-align: center;
				margin-right: 0;
			}
		}
		&.cell-hover{
			background:#fafafa;
		}
		&.b-b:after{
			left: 30upx;
		}
		&.m-t{
			margin-top: 16upx; 
		}
		.cell-more{
			align-self: baseline;
			font-size:$font-lg;
			color:$font-color-light;
			margin-left:10upx;
		}
		.cell-tit{
			flex: 1;
			font-size: $font-base + 2upx;
			color: $font-color-dark;
			margin-right:10upx;
		}
		.cell-tip{
			font-size: $font-base;
			color: $font-color-light;
		}
		switch{
			transform: translateX(16upx) scale(.84);
		}
	}
</style>
